#ifndef __LINKTREE_H__
#define __LINKTREE_H__
#include <string>
#include "DynamicArrayl.h"
using ElementType=std::string;

class TreeNode
{

public:
    TreeNode(const ElementType&date);
    
    void Connect(TreeNode*parent);
    //解绑
    void DisConnect(TreeNode*parent);
    void show(TreeNode*node,int n);
    static  void FreeNode(TreeNode*node);
    static  void FindByElement(TreeNode*node,const ElementType&element,DARRAY::DynamicArray&a);
    static int GetNodeHight(TreeNode*node);
    TreeNode*Getparent();
    std::string&GetDate();
    
    void SetDate(const ElementType &element)
    {
        date=element;
    }
private:

    ElementType date;//数据域
    TreeNode *parent;//双亲指针
    TreeNode*firstchild;//孩子指针
    TreeNode*nextSbling;//下一个兄弟指针


};

class LinkTree
{

public:
    LinkTree();
    LinkTree(const ElementType &element);
    ~LinkTree();
    TreeNode*GetRoot();
    void show();
    DARRAY::DynamicArray FindByElement(const ElementType &element);
    int GetTreeHight();
    std::string GetNodePath(TreeNode*node);
   
private:
    TreeNode*root;//根节点

};











#endif



